package com.zkh.myframe.core;

import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

import com.zkh.myutils.system.ConfigLoader;

/**
 * 异步调用线程池工具类
 */
public class AsyncThreadPoolUtils {
	/**
	 * 线程池大小
	 */
	private static final int THREAD_POOL_SIZE = Math.max(Integer.parseInt(ConfigLoader.getString("frame.asyncThreadPoolSize", "10", true)), 10);
	/**
	 * 定时任务
	 */
	private static ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(THREAD_POOL_SIZE, THREAD_POOL_SIZE, 0, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>());

	/**
	 * 提交任务
	 * @param task 自定义任务
	 */
	public static void submitTask(Runnable task) {
		threadPoolExecutor.submit(task);
	}

}
